// Copyright 叶湘 ( weixin:yexiang841, email:yexiang841@qq.com ), Shitouren Studio. All Rights Reserved.

#include "PawnState/Q3D_CPPU_PawnState.h"
#include "PawnState/Q3D_CPPI_PawnState.h"

void UQ3D_CPPU_PawnState::Q3D_F_PlayerIndex_Get(int32 &int_player_index) const
{
    if (!this->Ptr_A_Pawn)
    {
        int_player_index = 0;
        return;
    }
    IQ3D_CPPI_PawnState *ptr_i_pawn_state = Cast<IQ3D_CPPI_PawnState>(this->Ptr_A_Pawn);
    if (!ptr_i_pawn_state)
    {
        int_player_index = 0;
        return;
    }
    ptr_i_pawn_state->Execute_Q3D_IF_PlayerIndex_Get(this->Ptr_A_Pawn, int_player_index);
    return;
}

void UQ3D_CPPU_PawnState::Q3D_F_TextDisplayname_GetFull(FText &text_display_name) const
{
    text_display_name = FText::FromString(this->String_NickName);
    return;
}

void UQ3D_CPPU_PawnState::Q3D_F_TextDisplayname_GetForward(int int_len_limit, FText &text_display_name) const
{
    // 如果为空直接返回
    if (this->String_NickName.IsEmpty())
    {
        text_display_name = FText::FromString(this->String_NickName);
        return;
    }
    // 如果参数不合理直接返回
    if (int_len_limit < 4)
    {
        text_display_name = FText::FromString(this->String_NickName);
        return;
    }
    // 如果限制过大直接返回
    if (int_len_limit >= this->String_NickName.Len())
    {
        text_display_name = FText::FromString(this->String_NickName);
        return;
    }
    // 右侧截断
    text_display_name = FText::FromString(this->String_NickName.Left(int_len_limit - 2) + "...");
    return;
}

void UQ3D_CPPU_PawnState::Q3D_F_TextDisplayname_GetBackward(int int_len_limit, FText &text_display_name) const
{
    // 如果为空直接返回
    if (this->String_NickName.IsEmpty())
    {
        text_display_name = FText::FromString(this->String_NickName);
        return;
    }
    // 如果参数不合理直接返回
    if (int_len_limit < 4)
    {
        text_display_name = FText::FromString(this->String_NickName);
        return;
    }
    // 如果限制过大直接返回
    if (int_len_limit >= this->String_NickName.Len())
    {
        text_display_name = FText::FromString(this->String_NickName);
        return;
    }
    // 左侧截断
    text_display_name = FText::FromString(this->String_NickName.Right(int_len_limit - 2) + "...");
    return;
}

void UQ3D_CPPU_PawnState::Q3D_F_TextDisplayname_GetTwoway(int int_len_limit, FText &text_display_name) const
{
    // 如果为空直接返回
    if (this->String_NickName.IsEmpty())
    {
        text_display_name = FText::FromString(this->String_NickName);
        return;
    }
    // 如果参数不合理直接返回
    if (int_len_limit < 4)
    {
        text_display_name = FText::FromString(this->String_NickName);
        return;
    }
    // 如果限制过大直接返回
    if (int_len_limit >= this->String_NickName.Len())
    {
        text_display_name = FText::FromString(this->String_NickName);
        return;
    }
    // 中间截断
    int int_half_len_tmp = (int_len_limit - 2) / 2;
    text_display_name = FText::FromString(this->String_NickName.Left(int_half_len_tmp) + "..." + this->String_NickName.Right(int_half_len_tmp));
    return;
}
